require "fileutils"

module Rosarla
	# Give: (Optional) Command to be executed with each file
	# Expect: nil
	def self.typescript(given_command = "")
		
		the_path = "./assetsBuild/app/"
		the_end_path = "./assets/"
		the_files = self.get_files(the_path)
		
		(the_files).each do |this_file|
			
			%x(tsc #{this_file}#{given_command})
			new_file = this_file.gsub(".ts", ".js")
			output_file = new_file.gsub(the_path, the_end_path)
			FileUtils.mv(new_file, output_file)
			# puts "'#{this_file}' successfully compiled to '#{output_file}'."
		end
		
	end
	
end